﻿@{
    ViewBag.Title = "";
    Layout = "~/Views/Shared/_Form.cshtml";
 }

<form id="form" class="form-horizontal m" role="form" > 
        <div class="form-group">
            <label class="col-sm-3 control-label ">项目编号<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="code" name="Code" col="Code" type="text" class="form-control required " placeholder="请输入项目编号" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">项目名称<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="name" name="Name" col="Name" type="text" class="form-control required " placeholder="请输入项目名称" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">合同编号<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="contractCode" name="ContractCode" col="ContractCode" type="text" class="form-control required " placeholder="请输入合同编号" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">渠道Id<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="customerId" name="CustomerId" col="CustomerId" type="text" class="form-control required " placeholder="请输入渠道Id" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">渠道名称<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="customerName" name="CustomerName" col="CustomerName" type="text" class="form-control required " placeholder="请输入渠道名称" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">渠道经理<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="customerUser" name="CustomerUser" col="CustomerUser" type="text" class="form-control required " placeholder="请输入渠道经理" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">联系方式<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="customerUserPhone" name="CustomerUserPhone" col="CustomerUserPhone" type="text" class="form-control required " placeholder="请输入联系方式" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">出发时间<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="departureDate" name="DepartureDate" col="DepartureDate" type="text" class="form-control required " placeholder="请输入出发时间" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">回程时间<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="returnDate" name="ReturnDate" col="ReturnDate" type="text" class="form-control required " placeholder="请输入回程时间" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">成人数量<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="adultTotal" name="AdultTotal" col="AdultTotal" type="text" class="form-control required " placeholder="请输入成人数量" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">儿童数量<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="childTotal" name="ChildTotal" col="ChildTotal" type="text" class="form-control required " placeholder="请输入儿童数量" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">领队人数<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="teamLeader" name="TeamLeader" col="TeamLeader" type="text" class="form-control required " placeholder="请输入领队人数" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">销售人员<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="saleManagerId" name="SaleManagerId" col="SaleManagerId" type="text" class="form-control required " placeholder="请输入销售人员" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">销售人员<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="saleManagerName" name="SaleManagerName" col="SaleManagerName" type="text" class="form-control required " placeholder="请输入销售人员" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">参与人员<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="involveId" name="InvolveId" col="InvolveId" type="text" class="form-control required " placeholder="请输入参与人员" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">汇率<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="rate" name="Rate" col="Rate" type="text" class="form-control required " placeholder="请输入汇率" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">销售金额<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="saleAmount" name="SaleAmount" col="SaleAmount" type="text" class="form-control required " placeholder="请输入销售金额" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">成本支出<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="costAmount" name="CostAmount" col="CostAmount" type="text" class="form-control required " placeholder="请输入成本支出" />
            </div>
        </div>
</form>

<script type="text/javascript">
    var id = frame.request("id");
    $(function () {
        getForm();
    });

    function getForm() {
        if (!!id) {
            frame.ajax({
                url: '@Url.Content("/Sale/ProjectEntity/SetForm")' + '?id=' + id,
                type: 'get',
                success: function (obj) {
                    if (obj.success) {
                        $('#form').setWebControls(obj.data);
                    }
                }
            });
        }
        else {
            var defaultData = {};
            $('#form').setWebControls(defaultData);
        }
    }

    function saveForm(index) {
        if ($('#form').validate().form()) {
            var postData = $('#form').getWebControls({ Id: id });
            frame.ajax({
                url: '@Url.Content("/Sale/ProjectEntity/SaveForm")',
                type: 'post',
                data: postData,
                success: function (obj) {
                    if (obj.success) {
                        frame.msgSuccess(obj.message);
                        parent.searchGrid();
                        parent.layer.close(index);
                    }
                    else {
                        frame.msgError(obj.message);
                    }
                }
            });
        }
    }
</script>

